#include <iostream>
using namespace std;
//判断是不是闰年
int p_day[13] = {31,28,31,30,31,30,31,31,30,31,30,31};

bool judge(int year)
{
    if(((!year % 4 )&& year %100) || !(year  % 400 ))
    {
        return true;
    }
    return false;
}
int sub(int m,int d,int j)
{
    int n_m = 1,n_d = 1;
    int res = 0;
    while(n_m != m && n_d != d)
    {
        if(n_d == p_day[n_m] && n_m != 2)
        {
            n_m++;
            n_d = 1;
        }
        if(n_m == 2)
        {
            if(j)
            {
                if(n_d == p_day[2] + 1)
                {
                    n_d = 1;
                    n_m++;


                }
            }
            else {
                if(n_d == p_day[2])
                    {
                        n_d = 1;
                        n_m++;


                    }
            }
            res++;
            n_d++;
        }
    }
    return res + 1;
}
int main() {
    int y ,m,d;
    cin >> y >> m >> d;
    bool j = judge(y);
    cout << sub(m,d,j) << endl;
    return 0;
    
}
// 64 位输出请用 printf("%lld")